# -*- encoding:utf-8 -*-
from collections import Counter

'''
t字符串是s字符串的anagram
即该两个字符串经排序后相等
或该两个字符串包含字符的频率相等
1 对s&t进行排序，再对比
2 hash，循环对比
'''
#可优化，65.98%
class Solution(object):
	def isAnagram(self, s, t):
		if len(s) != len(t):
			return False
		sHash = Counter(s)
		tHash = Counter(t)
		for k in sHash:
			if tHash.get(k) is False or sHash[k] != tHash[k]:
				return False
		return True



s = "a"
t = "ab"
ob = Solution()
print ob.isAnagram(s,t)